package com.xhsj.user.lsm.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xhsj.user.sms.base.BaseService;
import com.xhsj.user.lsm.entity.TbBadgesProcessNode;
import com.xhsj.user.lsm.mapper.TbBadgesProcessNodeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * <p>
 * 流程节点表 服务实现类
 * </p>
 *
 * @author suxiaolin
 * @since 2020-03-16
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TbBadgesProcessNodeService extends BaseService<TbBadgesProcessNodeMapper, TbBadgesProcessNode>{
    @Autowired
    private TbBadgesProcessNodeMapper dao;


    /**
     * 获取第一个节点信息
     * @author 苏小林
     * @date 2020/3/17 10:52
     */
    public TbBadgesProcessNode getFirstNode(Integer type,Integer dealWith) {
        QueryWrapper<TbBadgesProcessNode> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id","0");
        queryWrapper.eq("type",type);
        queryWrapper.eq("deal_with",dealWith);
        queryWrapper.isNotNull("next_node_id");
        TbBadgesProcessNode one = this.getOne(queryWrapper);
        return one;
    }

    public Map<String, Object> getNextNodeId(String nodeId, Integer status,Integer type) {
        return dao.getNextNodeId(nodeId,status,type);
    }
}
